package com.sinosoft.lk.core.controller.client;

import com.sinosoft.lk.core.helper.JedisHelper;
import com.sinosoft.lk.core.utils.CookieUtils;
import com.sinosoft.lk.core.utils.StringUtils;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author 绫小路
 * @Date 2021/3/4
 */
public class AuthenticationController {

  public static boolean check(HttpServletRequest request, String ssoSessionIdName) {
    String sessionId = CookieUtils.getValue(ssoSessionIdName, request);
    if (StringUtils.isEmpty(sessionId)) {
      return false;
    }

    boolean exists = JedisHelper.exists(sessionId);
    if (!exists) {
      return false;
    }
    return true;
  }
}
